package com.homework.ch05;

import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Scanner;

/**
 * @author yang
 * @date 2024-03-26
 */
public class Test {
    public static void main(String[] args) throws Exception{
        System.out.print("请输入年份:");
        Class<Scanner> scannerClass = Scanner.class;
        Constructor<Scanner> s = scannerClass.getConstructor(InputStream.class);
        Scanner scanner = s.newInstance(System.in);
        Method method = scannerClass.getMethod("nextInt");
        int year = (int) method.invoke(scanner);
        System.out.println(year);
        if ((year % 4 == 0 && year % 100 != 0 )|| year % 400 == 0 ){
            System.out.println("这是闰年");
        }else {
            System.out.println("这是平年");
        }
    }
}
